using System.Collections.Generic;

namespace Be.Timvw.Framework.Domain.Specifications
{
    public class AndSpecification<T> : CompositeSpecification<T>
    {
        public AndSpecification(IEnumerable<ISpecification<T>> specifications)
        : base(specifications)
        {
        }

        public override bool IsSatisfiedBy(T item)
        {
            foreach(ISpecification<T> specification in this.Specifications)
            {
                if(!specification.IsSatisfiedBy(item))
                {
                    return false;
                }
            }

            return true;
        }
    }
}